const HtmlWebpackPlugin = require('html-webpack-plugin')
const HtmlMinimizerPlugin = require('html-minimizer-webpack-plugin')

const { resolve } = require('path')
const htmlPublicPath = resolve(__dirname, 'build')

module.exports = {
  entry: './src/js/index.js',
  output: {
    filename: 'js/built.js',
    path: htmlPublicPath,
    publicPath: './',
  },
  module: {
    rules: [
    ]
  },
  // https://webpack.docschina.org/plugins/html-minimizer-webpack-plugin/#minify
  // optimization: {
  //   minimize: true,
  // 下面会把所有默认值替换成下面，注意啊，不是根据某个属性进行替换
  //   minimizer: [
  //     new HtmlMinimizerPlugin({
  //       minimizerOptions: {
  //         // 移除空格
  //         collapseWhitespace: true,
  //         // 移除注释
  //         removeComments: true,
  //       },
  //     }),
  //   ],
  // },
  plugins: [
    new HtmlWebpackPlugin({
      template: './src/index.html'
    })
  ],
}